package test4;

import java.io.*;
import java.net.Socket;

public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1",9999);

        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("Java_11_23\\Client.png"));
        BufferedOutputStream bos = new BufferedOutputStream(socket.getOutputStream());

        byte[] bytes = new byte[1024];
        int len;
        while((len = bis.read(bytes)) != -1) {
            bos.write(bytes,0,len);
        }
        bos.flush();
        socket.shutdownOutput();

        InputStream is = socket.getInputStream();
        InputStreamReader isr = new InputStreamReader(is);
        int b;
        while((b = isr.read()) != -1) {
            System.out.print((char)b);
        }
        socket.close();
    }
}
